package jiang.commom;

import javax.servlet.ServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.util.SavedRequest;

public class WebUtil {
	public static String getOriginalUrl(ServletRequest request) {
		SavedRequest savedRequest = null;
		String originalUrl = null;
		Subject subject = SecurityUtils.getSubject();
		Session session = subject.getSession(false);
		if (session != null) {
			savedRequest = (SavedRequest) session
					.getAttribute("shiroSavedRequest");
		}
		if(savedRequest != null){
			originalUrl = savedRequest.getRequestUrl();
			session.removeAttribute("shiroSavedRequest");
		}
		return originalUrl;
	}
}
